<%@page import="com.dfhc.ISystemConstant"%>
<%@page import="com.dfhc.util.CryptoHelper"%>
<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<%@ taglib uri="/dfhc" prefix="dfhc" %>
<!-- 全局js 和css包 -->
<%@ include file="/jsp/include/web/new/global.jsp" %>
<title>权限类别管理</title>
</head>
<body>

<dfhc:template templateUrl="/pubController/getLayoutTemp/?jspUrl=/temp/huiBodyTemp" >	 
 	<dfhc:region name="searchRegion"> 
	<form name="searchForm" id="searchForm" action="">
	<dfhc:div templateId="h_ui_div_search">
		<dfhc:input templateId="h_ui_search_input" placeholder="输入名称" id="" name="name" />
		<dfhc:button templateId="h_ui_search_button" id="" name="" onclick="javascript:_searchData();" />
	</dfhc:div>
	</form>
     </dfhc:region> 
     <dfhc:region name="buttonRegion">
        <dfhc:div templateId="h_ui_div_table_button">
        <dfhc:span templateId="h_ui_button_span">

         <dfhc:button templateId="h_ui_add_button" onclick="_showPage('添加','/rmauthorize/addPage','550','750')" />
         <dfhc:button templateId="h_ui_update_button" onclick="singleEdit('修改','/rmauthorize/showPage','550','750')" />
		 <dfhc:button templateId="h_ui_delete_button" onclick="singleDelete('/rmauthorize/delete')" />
		</dfhc:span>
		<dfhc:span templateId="h_ui_total_record_num_span">${RM_PAGE_VO.recordCount}</dfhc:span>		
	    </dfhc:div>		       
     </dfhc:region> 
    <dfhc:region name="tableRegion">
    	<dfhc:table templateId="table_h_ui" >    	
		<dfhc:thead>
			<dfhc:tr> 
				<dfhc:th width="25">
				   <dfhc:checkbox name="allId" />&nbsp;&nbsp;&nbsp;序号
				</dfhc:th>	
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" >名称</dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" >业务关键字</dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" >是否单独建表</dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" >授权资源表名</dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" >授权记录表名</dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" >授权资源附加数据表名</dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" >权限配置选项类型</dfhc:title>
				</dfhc:th>
				<dfhc:th width="100">
				   <dfhc:title templateId="title_h_ui" >描述</dfhc:title>
				</dfhc:th>
			</dfhc:tr>
    	   </dfhc:thead>			
		</dfhc:table>           
     </dfhc:region>        
     <dfhc:region name="footer"> 
     </dfhc:region> 
</dfhc:template>    
 
<script type="text/javascript">
var _table;
$(function(){
	_table = $('.table-sort').DataTable({	
	     dom: 'Zlfrtip',	   		
		 ajax : function(data, callback, settings) {
		       var param =  splitParameter(data); 
                $.ajax({  
                        type: "POST",  
                        url: getRootPath()+'<%=CryptoHelper.encryptUrl(request,"/rmauthorize/ajaxList")%>',  
                        cache : false,  //禁用缓存  
                        data:param,   
                        dataType: "json",  
                        success: function(result) {  
                                //异常判断与处理  
                                if (result.status=='0') {  
                                    alert(result.message);  
                                    return;  
                                }  
                                //封装返回数据  
                                var returnData = {};  
                                returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回  
                                returnData.recordsTotal = result.recordsTotal;//总记录数  
                                returnData.recordsFiltered = result.recordsTotal;//后台不实现过滤功能，每次查询均视作全部结果  
                                returnData.data = result.data;  
                                //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染  
                                //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕  
                                callback(returnData);  
                                //更新总记录数
                                $("#totalRecodSpan").html('共有数据：<strong>'+result.recordsTotal+'</strong> 条</span>');
                                $('#DataTables_Table_0').on('dblclick', 'tbody tr',function() {
                                    var data = _table.row( this ).data();
                                    var ur=getRootPath()+'<%=CryptoHelper.encryptUrl(request,"/rmauthorize/details")%>';
                                    var id=data.id;
                                    details('详情',ur,'550','510',id);
                                } );
                        },  
                        error: function(XMLHttpRequest, textStatus, errorThrown) {  
                            alert("查询失败");  
                        }  
                    });  
            },  
		"columns": [
		  {
		    "data":"id",
                    "width":"50px",
			"render":function(data,type,row,meta){
			   var content='<input type="checkbox"  name="allId" value="'+row.id+'"/>';
			   return content; 
			}
		  },
		  {"data":"name"},
		  {"data":"bs_keyword"},
		  {	   
			    "data":"is_alone_table",
			    "defaultContent":"",
				render:function(data,type,row,meta){
					var content='';
					if(row.is_alone_table=='1'){
					 content='是';
					}else{
					 content='否';
					}
				   return content; 
				}
			  },
		  {"data":"authorize_resource_table_name"},
		  {"data":"authorize_resrec_table_name"},
		  {"data":"authorize_affix_table_name"},
		  {	   
			    "data":"settiing_option",
			    "defaultContent":"",
				render:function(data,type,row,meta){
					var content='';
					if(row.settiing_option=='1'){
					 content='单选';
					}else{
					 content='定制';
					}
				   return content; 
				}
			  },
		  {"data":"description"}
		],
		"columnDefs": [ {"searchable": false,
            "orderable": false,
            "targets": 0 }]  				
	}); 
    _table.on( 'draw.dt', function () {
    var PageInfo = $('.table-sort').DataTable().page.info();
         _table.column(0, { page: 'current' }).nodes().each( function (cell, i) {
            cell.innerHTML = cell.innerHTML+"&nbsp;&nbsp;&nbsp;"+(i + 1);
            //如果翻页后，想继续保持序号加上PageInfo.start
        } );
    } );

});
/*拼接参数*/
function splitParameter(data){
	 var paramJsonStr = $(searchForm).serializeObject();
	 //组装 排序参数
	 if(data.order && data.order.length && data.order[0]){
	  data.sort = data.columns[data.order[0].column].data;
      if(data.sort!='0'){
      	data.dir = data.order[0].dir;
      }else{
        data.sort ='';
        data.dir='';
      }
	}  
	var retVal;
	retVal = $.extend( {}, data,paramJsonStr); 
	return retVal;
}


$.fn.serializeObject=function(){
    var o = {};
    var a = this.serializeArray();
    $.each(a, function() {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};
/**
 * 查询rm_authorize
 */
function _searchData(){	
	$('.table-sort').DataTable().ajax.reload();
} 




</script> 
</body>
</html>
